package com.hzsai.controller;

import com.hzsai.service.AsyncService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * hzsai 2019/8/1
 * usage:
 **/
@Api(tags = "spring的异步线程")
@RestController
@RequestMapping("/async")
public class AsyncController {

    @Autowired
    private AsyncService service = null;

    // /async/generate
    @ApiOperation(value = "生成")
    @GetMapping("/generate")
    public Map<String, Object> generateReport() {
        Map<String, Object> ret = new HashMap<String, Object>();
        System.out.println("===--报表主线程名称: " + "【" + Thread.currentThread().getName() + "】--===");
        service.generateReport();
        System.out.println("===--报表主线程名称：" + "lalalala  ");
        ret.put("报表主线程名称", Thread.currentThread().getName());
        return ret;
    }
}
